package org.xcorpio.java8.chapter12;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.Chronology;
import java.time.chrono.JapaneseDate;
import java.util.Locale;

public class TimeZoneAndCalendar {

    public static void main(String[] args) {
        ZoneId systemDefault = ZoneId.systemDefault();
        System.out.println(systemDefault);
        ZoneId romeZone = ZoneId.of("Europe/Rome");
        LocalDate date = LocalDate.of(2016, Month.NOVEMBER, 11);
        System.out.println(date);
        System.out.println(date.atStartOfDay(romeZone));

        // Fixed offset from UTC/Greenwich
        System.out.println();
        ZoneOffset newYorkOffset = ZoneOffset.of("-05:00");
        LocalDateTime now = LocalDateTime.now();
        OffsetDateTime dateTimeInNewYork = OffsetDateTime.of(now, newYorkOffset);
        System.out.println(dateTimeInNewYork);

        // Using alternative calendar systems
        System.out.println();
        JapaneseDate japaneseDate = JapaneseDate.from(now);
        System.out.println(japaneseDate);
        Chronology chronology = Chronology.ofLocale(Locale.CHINA);
        ChronoLocalDate dateNow = chronology.dateNow();
        System.out.println(dateNow);
    }
}
